#ifndef __SUPERCAP_H
#define __SUPERCAP_H

#include "main.h"
#include "referee.hpp"

extern bool supercap_buffer_flag;

class Supercap {
   public:
    int  start(void);
    void update(uint8_t Data[8]);
    void set_power(uint16_t chassis_power_limit_, uint16_t output_power_limmit_, uint16_t input_power_limit_, uint16_t cap_contorl);
    void set_buffer_power(uint16_t chassis_buff_power_);
		void handle(void);
		void init(void);
    volatile float cap_v;  // 输入电压
    volatile float cap_i;    // 电容电压
    volatile int16_t state;  // 输入电流
    volatile float target_power;   // 目标功率
	 
   private:
    uint16_t chassis_power_limit_;
    uint16_t output_power_limmit_;
    uint16_t input_power_limit_;
    uint16_t cap_contorl;
    uint16_t chassis_buff_power_;

    static void timeout(void *parameter);
    rt_timer_t  timer_;  // 超级电容定时器
};

#endif
